﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace CastleDefenceGame
{
    public class Enemy
    {
        private Texture2D textureEnemy;
        private Vector2 Position;
        private Vector2 Direction;
        private Rectangle rectangleEnemy;
        private int HP;
        private int Speed;
        private int Damage;
        public Enemy(int hp, Vector2 position, int speed, int damage)
        {
            HP = hp;
            Position = position;
            Speed = speed;
            Damage = damage;
            Direction.X = speed;
        }
        public void LoadContent(ContentManager content, String textureName)
        {
            textureEnemy = content.Load<Texture2D>(textureName);
            rectangleEnemy = new Rectangle((int)Position.X, (int)Position.Y, textureEnemy.Width, textureEnemy.Height);
        }
        public void Update(GameTime gameTime, Fort fort)
        {
            if (!rectangleEnemy.Intersects(fort.rectangleFort))
            {
                Position += Direction;
                rectangleEnemy.X = (int)Position.X;
            }
        }
        public void Draw(SpriteBatch spriteBatch)
        { 
            spriteBatch.Draw(textureEnemy, Position, Color.White);
        }
    }
}
